[% setvar title Operators: Multiway comparisons %]
<div id="archive-notice">
    <h3>This file is part of the Perl 6 Archive</h3>
    <p>To see what is currently happening visit <a href="http://www.perl6.org/">http://www.perl6.org/</a></p>
</div>
<div class='pod'>
<a name='TITLE'></a><h1>TITLE</h1>
<p>Operators: Multiway comparisons</p>
<a name='VERSION'></a><h1>VERSION</h1>
<pre>  Maintainer: Damian Conway &lt;<a href='mailto:damian@conway.org'>damian@conway.org</a>&gt;
  Date: 4 Aug 2000
  Last Modified: 18 Sep 2000
  Mailing List: <a href='mailto:perl6-language@perl.org'>perl6-language@perl.org</a>
  Number: 25
  Version: 2
  Status: Frozen</pre>
<a name='ABSTRACT'></a><h1>ABSTRACT</h1>
<p>This RFC proposes that multiway comparisons such as:</p>
<pre>	if ( 0 &lt;= $x &lt; 10 ) {
		print &quot;digit&quot;
	}</pre>
<p>should do what the user means.</p>
<a name='DESCRIPTION'></a><h1>DESCRIPTION</h1>
<p>It is proposed that expressions involving multiple chained comparisons
should be automagically expanded to the equivalent binary conjunction. That is:</p>
<pre>	0 &lt;= $x &lt; 10</pre>
<p>is DWIMmed to:</p>
<pre>	0 &lt;= $x &amp;&amp; $x &lt; 10</pre>
<p>Furthermore, it is proposed that any operations, function calls, or subroutine
invocations should only be performed once in such expansions and that such
expansions should short-circuit on failure. That is:</p>
<pre>	$min &lt; nextval() &lt; $x+$y &lt; length $string</pre>
<p>should become:</p>
<pre>	do {
		my $tmp1, $tmp2;
		$min &lt; do{$tmp1=nextval} &amp;&amp;
		$tmp1 &lt; do{$tmp2=$x+$y} &amp;&amp;
		$tmp2 &lt; length $string;
	}</pre>
<a name='IMPLEMENTATION'></a><h1>IMPLEMENTATION</h1>
<p>As described above</p>
<a name='REFERENCES'></a><h1>REFERENCES</h1>
<p>None.</p>
</div>
